tooltip: Implement positioning using gdk_window_move_to_rect()
authorJonas Ådahl <jadahl@gmail.com>
Fri, 10 Aug 2018 15:11:46 +0000 (17:11 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Fri, 10 Aug 2018 16:32:54 +0000 (18:32 +0200)
commit14d22cb3233efbd7e9f8f6244179eccc2cc8beb8
treeddd6e71f7dbc9483b5237873ae8e2a5750ed1489
parent595f3902c8249d8fff50de7ebc59cce530f3c96c
tooltip: Implement positioning using gdk_window_move_to_rect()

In order to make tooltip positioning portable, make use of the
move_to_rect API. Some semantical changes are made, as identical
semantics cannot be implemented using the move-to-rect API.

Primarily the implemented semantics are:

Position the tooltip in the center pixels slightly below (defaults to 4
units below) the tooltipped widget. This is always the case for keyboard
driven tooltips; the case where it tries to avoid the pointer cursor is
not implemented.

For pointer position triggered tooltips, implement the following
additional semantics:

Use the current cursor size to determine the padding used to enlarge the
anchor rectangle. This is to try to avoid the cursor overlapping the
tooltip.

If the anchor rectangle is too tall (meaning if we'd be constrained
and flip on the Y axis, it'd flip too far away from the originally
intended position), rely only on the pointer position to position the
tooltip. The approximate pointer cursor rectangle is used as a anchor
rectangle. Ideally we should use the actual pointer cursor rectangle
(image used as well as hotspot coordinate), but we don't have API to
get that information.

If the anchor rectangle isn't to tall, just make sure the tooltip isn't
too far away from the pointer position on the X axis.

Closes: #134
Closes: #432
Closes: #574
Closes: #579
Closes: #878
gtk/gtktooltip.c
gtk/gtktooltipwindow.c